home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
LISP
/
XLISP
/
XLISP21S
/
sources
/
asm
/
longjmp
next >
Wrap
Text File
|
1992-02-17
|
1KB
|
56 lines
; setjmp/longjmp for Microway C 386
; Written by Tom Almy, placed in public domain.
; This is missing from the Microway distribution!
; The following needs to be put in a file "setjump.h"
; typedef int jmp_buf[11]; /* ip cs bp sp ds es fs gs si di bx */
; extern int setjmp(/*jmp_buf env*/);
; extern void longjmp(/*jmp_buf env, int val*/);
.386p
dataseg segment 'data'
dataseg ends
codeseg segment er dword public use32 'code'
assume cs:codeseg, ds:dataseg
public _setjmp,_longjmp
align 4
_setjmp proc near
mov eax, 4[esp] ; jmp_buf
mov edx, 0[esp] ; return address
mov 0[eax],edx ; ip
mov 8[eax],ebp ; other registers
lea edx, 4[esp] ; stack pointer (after return)
mov 12[eax],edx
mov 20[eax],es
mov 24[eax],fs
mov 28[eax],gs
mov 32[eax],esi
mov 36[eax],edi
mov 40[eax],ebx
xor eax, eax ; return zero
ret
_setjmp endp
align 4
_longjmp proc near
mov eax, 4[esp] ; arg
mov ecx, 8[esp] ; return value
mov esp, 12[eax] ; reset stack
push 0[eax] ; return ip value
mov ebp, 8[eax]
mov es, 20[eax]
mov fs, 24[eax]
mov gs, 28[eax]
mov esi, 32[eax]
mov edi, 36[eax]
mov ebx, 40[eax]
mov eax, ecx ; return value
or eax, eax ; mustnt be zero
jnz SHORT nonzero
inc eax
nonzero:
ret
_longjmp endp
codeseg ends
end